Add ARGTYPE_HIDDEN flag and 'nowarn' flag for stack filter
authorparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 17 Sep 2004 20:14:06 +0000 (20:14 +0000)
committerparkrrrr <parkrrrr@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 17 Sep 2004 20:14:06 +0000 (20:14 +0000)
gpsbabel/defs.h
gpsbabel/filter_vecs.c
gpsbabel/stackfilter.c
gpsbabel/testo
gpsbabel/vecs.c

index 807d3dc8288a6ac99b48783bbc2a8de92974e81a..cf4ad1c368095d5c9f4d32d181eea3f0791c2635 100644 (file)
@@ -325,6 +325,7 @@ void        vmem_realloc(vmem_t*, size_t);
 #define ARGTYPE_FILE     0x00000005
 #define ARGTYPE_OUTFILE  0x00000006
 #define ARGTYPE_REQUIRED 0x40000000
+#define ARGTYPE_HIDDEN   0x20000000
 
 #define ARGTYPE_TYPEMASK 0x00000fff
 #define ARGTYPE_FLAGMASK 0xfffff000
index aab1af133b3f6141af40150369d9fe18ce03e30e..f81c545b71c3e836eb62baf89ecf39f86f0845f1 100644 (file)
@@ -190,7 +190,8 @@ disp_filter_vecs(void)
                printf("        %-20.20s  %-50.50s\n",
                        vec->name, vec->desc);
                for (ap = vec->vec->args; ap && ap->argstring; ap++) {
-                       printf("          %-18.18s    %-.50s %s\n",
+                       if ( !(ap->argtype & ARGTYPE_HIDDEN )) 
+                               printf("          %-18.18s    %-.50s %s\n",
                                ap->argstring, ap->helpstring,
                                (ap->argtype&ARGTYPE_REQUIRED)?"(required)":"");
                }
index d581bbb52d5c5802f260134a3c05c7f8c93b0a10..d9a82d98a985c8d5f90320093cc9c08497ba4ec2 100644 (file)
@@ -33,6 +33,8 @@ static char *opt_discard = NULL;
 static char *opt_replace = NULL;
 static char *opt_swap = NULL;
 static char *opt_depth = NULL;
+static char *nowarn = NULL;
+static int  warnings_enabled = 1;
 static int  swapdepth = 0;
 
 static
@@ -52,6 +54,8 @@ arglist_t stackfilt_args[] = {
        {"swap", &opt_swap, "Swap waypoint list with <depth> item on stack", 
                NULL, ARGTYPE_BOOL},
        {"depth", &opt_depth, "Item to use when swapping", NULL, ARGTYPE_INT},
+       {"nowarn", &nowarn, "Suppress cleanup warning", NULL, 
+               ARGTYPE_INT | ARGTYPE_HIDDEN},
        {0, 0, 0, 0, 0}
 };
 
@@ -121,6 +125,10 @@ stackfilt_init(const char *args) {
        
        int invalid = 0;
        
+       if ( nowarn ) {
+               warnings_enabled = 0;
+       }
+       
        if ( opt_depth ) {
                swapdepth = atoi( opt_depth );
        }
@@ -163,7 +171,7 @@ void
 stackfilt_exit( void ) {
        struct stack_elt *tmp_elt = NULL;
  
-       if ( stack ) {
+       if ( warnings_enabled && stack ) {
                warning( MYNAME " Warning: leftover stack entries; "
                        "check command line for mistakes\n" );
        }       
index 8fc52b5e23a3e1a9b2a911ed3d544dcd9206ecae..fcd9d394a4dd0e9b0bd14899668a8da0c2bfe379 100755 (executable)
@@ -590,12 +590,9 @@ compare ${TMPDIR}/Glad_5.exp reference
 #
 # stack filter tests
 # These don't actually test for proper behavior, for now, but they do 
-# exercise all of the currently-extant filter code except for the "clean
-# up leftover stacks" code that would output a warning.  Of course, that 
-# code is the most likely to generate memory leaks, so maybe we need a 
-# 'nowarn' option to the stack filter so we can test it...
+# exercise all of the currently-extant filter code.
 #
 
-${PNAME} -i geo -f geocaching.loc -x stack,push,copy -x stack,push,copy -x stack,push -x stack,pop,replace -x stack,pop,append -x stack,push,copy -x stack,pop,discard -x stack,swap,depth=1 -x stack,pop -o arc -F ${TMPDIR}/stackfilt.txt
+${PNAME} -i geo -f geocaching.loc -x stack,push,copy,nowarn -x stack,push,copy -x stack,push -x stack,pop,replace -x stack,pop,append -x stack,push,copy -x stack,pop,discard -x stack,swap,depth=1 -o arc -F ${TMPDIR}/stackfilt.txt
 
 exit 0
index 3fab6bbee6fe9078e72b41f633b075ebd9d78414..3bfac7257cd38032aa9a7a5c1acef05f93d3e586 100644 (file)
@@ -523,9 +523,10 @@ disp_vecs(void)
        for (i=0;i<vc;i++) {
                printf(VEC_FMT, svp[i]->name, svp[i]->desc);
                for (ap = svp[i]->vec->args; ap && ap->argstring; ap++) {
-               printf("          %-18.18s    %-.50s %s\n",
-                       ap->argstring, ap->helpstring,
-                       (ap->argtype & ARGTYPE_REQUIRED)?"(required)":"");
+                       if ( !(ap->argtype & ARGTYPE_HIDDEN)) 
+                               printf("          %-18.18s    %-.50s %s\n",
+                               ap->argstring, ap->helpstring,
+                               (ap->argtype & ARGTYPE_REQUIRED)?"(required)":"");
                }
        }